package org.example.domain.strategy.model.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.types.common.Constants;

//策略实体
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {

    /**策略id*/
    private Long strategyId;
    /**策略描述*/
    private String strategyDesc;
    /**规则模型[1-抽奖策略规则,2-奖品规则]*/
    private String ruleModels;

    public String[] ruleModels(){
        if (ruleModels == null) return null;
        return ruleModels.split(Constants.SPLIT);
    }

    public String getRuleWeight() {
        String[] ruleModels = this.ruleModels();
        if (ruleModels == null) return null;
        for (String ruleModel : ruleModels) {
            if (ruleModel.equals("rule_weight")) return ruleModel;
        }
        return null;
    }
}
